import {createApp} from 'vue';
import ElementPlus from 'element-plus';
import store from '@/store';
import 'element-plus/dist/index.css';
import router from '@/router';
import WindowManager from '@/components/windowManager';
import Notification from '@/components/notification';
import directives from '@/directives';
import icons from '@/icons';
import MyFroala from '@/components/MyFroala';
import {froalaConfig} from '@/components/MyFroala';

window.onerror = function(msg, url, line) {
  console.error(msg, url, line)
};

function resolveErrorHandler(app) {
  app.config.errorHandler = function (err) {
    console.error("global", err);
  };
}

export default function (component) {
  if (store.getters['user/userInfo']) {
    froalaConfig.imageUploadParams['ff-token'] = store.getters['user/userInfo'].token;
    froalaConfig.fileUploadParams['ff-token'] = store.getters['user/userInfo'].token;
  }
  let app = createApp(component);
  resolveErrorHandler(app);
  app.use(ElementPlus);
  app.use(icons);
  app.use(router);
  app.use(store);
  app.use(WindowManager);
  app.use(Notification);
  app.use(directives);
  app.use(MyFroala);
  return app
};




